package com.ssm.modules.controller;

import com.ssm.common.bean.VResponse;
import com.ssm.modules.entity.Grade;
import com.ssm.modules.service.IGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @email: dong980514280@gmail.com
 * @author: Dong
 * @date: 2018/12/18
 * @time: 17:27
 * 班级Controller
 */
@Controller
public class GradeContoller {
@Autowired
    private IGradeService iGradeService;
    @ResponseBody
    @RequestMapping(value = "/selectGrade",method = RequestMethod.GET)
    public VResponse <List<Grade>> selectAll(){
        List<Grade> grade = iGradeService.selectAll();
        return VResponse.success("grade");

    }
    @ResponseBody
    @RequestMapping(value = "/addGrade",method = RequestMethod.POST)
    public VResponse<Object> addGrade(@RequestBody Grade grade){
        iGradeService.addGrade(grade);
        VResponse.error(0,"添加失败");
        return VResponse.success("添加成功");

    }
    @ResponseBody
    @RequestMapping(value = "/updateGrade",method = RequestMethod.PUT)
    public VResponse<Object> updateGrade(@RequestBody Grade grade){
        this.iGradeService.updateGrade(grade);
        return VResponse.success("修改成功");

    }
    @ResponseBody
    @RequestMapping(value = "/deleteGrade",method = RequestMethod.DELETE)
    public VResponse<Object>deleyeGrade(@RequestParam("id") int id){
        this.iGradeService.deleteGrade(id);
        return VResponse.success("删除成功");
    }

}
